//当前时间转字符串类型
Date.prototype.DateToString = function(type) {
    const Y = this.getFullYear();
    const Mon = this.getMonth() + 1;
    const Day = this.getDate();
    const H = this.getHours();
    const Min = this.getMinutes();
    const S = this.getSeconds();
    //自定义选择想要返回的类型
    if (type == "" || null == type) {
        return `${Y}-${Mon}-${Day} ${H}:${Min}:${S}`
    } else if (type == "y") {
        return `${Y}-${Mon}-${Day}`
    } else if (type == "h") {
        return `${H}:${Min}:${S}`
    } else {
        return `${Y}-${Mon}-${Day} ${H}:${Min}:${S}`
    }
}

function timeStamptoDate(data, type) {
    if ('' == data || null == data) {
        return "还没有时间"
    } else {
        var _data = data;
        //如果是13位正常，如果是10位则需要转化为毫秒
        if (String(data).length == 13) {
            _data = data
        } else {
            _data = data * 1000
        }
        const time = new Date(_data);
        return time.DateToString(type);
    }
}